package com.spatio.serving.basic.service.template.server.web;



/**
 * @author lei.zhao
 */
//@EnableWebMvc


//    @Resource
//    private InitSpatioLoginContextInterceptor initSpatioLoginContextInterceptor;
//    @Resource
//    private VerifySignatureInterceptor verifySignatureInterceptor;

/*    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("http://localhost:9001") // your reactjs URL
                .allowedMethods("GET", "POST", "PATCH", "PUT", "DELETE")
                .allowedHeaders("Content-Type") // Adjust headers you need to allow
                .allowCredentials(true); // Add only if you want to access cookie
    }*/

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(initSpatioLoginContextInterceptor)
//                .addPathPatterns("/**").excludePathPatterns("/error", "/metrics")
//                .order(1);
//        registry.addInterceptor(verifySignatureInterceptor)
//                .addPathPatterns("/**").excludePathPatterns("/error", "/metrics")
//                .order(2);
//    }

/*    @Override
    public void addCorsMappings(CorsRegistry registry) {

        registry.addMapping("/**")
                .allowedOrigins("http://localhost:3000") // replace "*" with the specific origin
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
                .allowCredentials(true)
                .maxAge(3600)
                .allowedHeaders("*");

    }*/




import com.spatio.serving.basic.service.template.server.Interceptor.JWTInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptAdapter implements WebMvcConfigurer {

    @Autowired
    private JWTInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/api/v1/user/login")
                .excludePathPatterns("/api/v1/user/test")
                .excludePathPatterns("/api/v1/user/code");

    }

}
